import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';

/**
 * 首页模块类型枚举
 */
export enum HomeModuleType {
  IMAGE_CARD = 1,        // 图片卡片
  IMAGE_TEXT_CARD = 2,   // 图文卡片
  PURE_IMAGE = 3,        // 纯图片
  VIDEO_CARD = 4,        // 视频卡片
  ENTRANCE_CARD = 5,     // 入口卡片
  IMAGE_TEXT_LIST = 6    // 图文列表卡片
}

@Entity('home_modules')
export class HomeModule {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column({
    type: 'enum',
    enum: HomeModuleType,
    comment: '模块类型'
  })
  type!: HomeModuleType;

  @Column({
    type: 'varchar',
    length: 50,
    comment: '模块名称'
  })
  moduleName!: string;

  @Column({
    type: 'varchar',
    length: 100,
    nullable: true,
    comment: '标题'
  })
  title!: string;

  @Column({
    type: 'varchar',
    length: 255,
    nullable: true,
    comment: '图片地址'
  })
  imageUrl!: string;

  @Column({
    type: 'varchar',
    length: 255,
    nullable: true,
    comment: '视频地址'
  })
  videoUrl!: string;

  @Column({
    type: 'text',
    nullable: true,
    comment: '文案内容'
  })
  content!: string;

  @Column({
    type: 'varchar',
    length: 500,
    nullable: true,
    comment: '描述'
  })
  description!: string;

  @Column({
    type: 'boolean',
    default: true,
    comment: '是否生效'
  })
  isActive!: boolean;

  @Column({
    type: 'int',
    default: 0,
    comment: '排序号'
  })
  sortOrder!: number;

  @CreateDateColumn({
    type: 'timestamp',
    comment: '创建时间'
  })
  createTime!: Date;

  @Column({
    type: 'varchar',
    length: 36,
    comment: '创建人ID'
  })
  createBy!: string;

  @UpdateDateColumn({
    type: 'timestamp',
    comment: '修改时间'
  })
  updateTime!: Date;

  @Column({
    type: 'varchar',
    length: 36,
    comment: '修改人ID'
  })
  updateBy!: string;
} 